package com.party.core.service.collect.impl;

import com.party.common.paging.Page;
import com.party.common.utils.StringUtils;
import com.party.core.dao.read.collect.SystemPlatformCollectReadDao;
import com.party.core.dao.write.collect.SystemPlatformCollectWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.collect.SystemPlatformCollect;
import com.party.core.service.collect.ISystemPlatformCollectService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @Description:
 * @Author: yangshoukun
 * @Date: 2018/6/20 18:56
 */
@Service
public class SystemPlatformCollectService implements ISystemPlatformCollectService {

    @Autowired
    private SystemPlatformCollectReadDao systemPlatformCollectReadDao;
    
    @Autowired
    private SystemPlatformCollectWriteDao systemPlatformCollectWriteDao;

    @Override
    public String insert(SystemPlatformCollect systemPlatformCollect) {
        BaseModel.preInsert(systemPlatformCollect);
        boolean result = systemPlatformCollectWriteDao.insert(systemPlatformCollect);
        if (result){
            return systemPlatformCollect.getId();
        }
        return null;
    }

    @Override
    public boolean update(SystemPlatformCollect systemPlatformCollect) {
        systemPlatformCollect.setUpdateDate(new Date());
        return systemPlatformCollectWriteDao.update(systemPlatformCollect);
    }

    @Override
    public boolean deleteLogic(String id) {
        if (StringUtils.isEmpty(id)) {
            return false;
        }
        return systemPlatformCollectWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        if (StringUtils.isEmpty(id)) {
            return false;
        }
        return systemPlatformCollectWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return false;
        }
        return systemPlatformCollectWriteDao.batchDeleteLogic(ids);
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return false;
        }
        return systemPlatformCollectWriteDao.batchDelete(ids);
    }

    @Override
    public SystemPlatformCollect get(String id) {
        return systemPlatformCollectReadDao.get(id);
    }

    @Override
    public List<SystemPlatformCollect> listPage(SystemPlatformCollect systemPlatformCollect, Page page) {
        return systemPlatformCollectReadDao.listPage(systemPlatformCollect, page);
    }

    @Override
    public List<SystemPlatformCollect> list(SystemPlatformCollect systemPlatformCollect) {
        return listPage(systemPlatformCollect, null);
    }

    @Override
    public List<SystemPlatformCollect> batchList(Set<String> ids, SystemPlatformCollect systemPlatformCollect, Page page) {
        return null;
    }

    @Override
    public SystemPlatformCollect findByCreateDate(Date createDate) {
        return systemPlatformCollectReadDao.findByCreateDate(createDate);
    }
}
